package com.mzkj.wanjulaile.mobile.api.modules.toy.entity;

import com.mzkj.common.utils.StringUtils;
import com.mzkj.wanjulaile.mobile.api.common.entity.DataEntity;
import com.mzkj.wanjulaile.mobile.api.modules.appointment.entity.AppointmentCollection;
import com.mzkj.wanjulaile.mobile.api.modules.brand.entity.Brand;
import com.mzkj.wanjulaile.mobile.api.modules.category.entity.SubCategory;
import com.mzkj.wanjulaile.mobile.api.modules.stock.entity.Stock;
import org.hibernate.validator.constraints.Length;

import java.util.List;

/**
 * Created by wangxw on 2016/12/12.
 */
public class Toy extends DataEntity<Toy> {
    private static final long serialVersionUID = 1L;
    private Brand brand;        // 品牌id
    private String toyModel;    //产品型号
    private String toyNumber;        // 产品编号
    private String code;
    private String name;        // 产品名称
    private String isBig;        // 是否为大玩具(1:是 0:否)
    private String params;        // 玩具详情参数
    private int marketPrice;        // 市场价(以分为单位)
    private String ageEnd;        // 适合年龄最大值(月)
    private String ageStart;        // 适合年龄起始值（月）
    private String sex;        // 宝宝性别（0:男 1:女)
    private int sort;        // 最新上架
    private int popularity;        // 人气热度
    private String onShelf;        // 是否上架(0:下架 1:上架)
    private String details;     // 商品详情
    private String instructionName;  //说明书名称 (已无效)
    private String instructionPath;   // 说明书路径(已无效)
    private Integer retailPrice;    //零售价
    private Integer star;   //玩具星值

    private Stock stock;

    private List<Image> images;

    private List<SubCategory> subCategories;

    private AppointmentCollection appointmentCollection;

    //微信端接收查询参数
    private String ages;
    private String brands;
    private String sorts;
    private String productCategorys; //分类类型
    private String existStock;  //是否有库存  0:无  1:有

    private List<String> paramList;

    private List<String> subCategoryIdList;

    /**
     * 年龄段 展示使用
     */
    private String ageSpan;
//    /** 锻炼能力的分类类型 */
    private String type;

    /**
     * 订单上的玩具  展示使用
     */
    private Integer toyCount;
    private Integer toyStatus;
    private Integer toyStatusLast; //存储临时状态

    public String getAgeSpan() {
        if (StringUtils.isEmpty(ageEnd)) {
            ageEnd = "0";
        }
        if (StringUtils.isEmpty(ageStart)) {
            ageStart = "0";
        }
        if (ageEnd.equals("0")) {
            if (Integer.valueOf(ageStart) % 12 == 0) {
                ageSpan = Integer.valueOf(ageStart) / 12 + "岁以上";
            } else if (Integer.valueOf(ageStart) ==18){
                ageSpan = "1.5岁以上";
            }else{
                ageSpan = ageStart + "月以上";
            }
        } else if ((Integer.valueOf(ageStart) % 12 == 0 || Integer.valueOf(ageStart) == 18) && (Integer.valueOf(ageEnd) % 12 == 0 || Integer.valueOf(ageEnd) == 18)) {
            String v1;
            String v2;
            if (Integer.valueOf(ageStart) == 18) {
                v1 = "1.5";
            } else {
                v1 = Integer.valueOf(ageStart) / 12 + "";
            }
            if (Integer.valueOf(ageEnd) == 18) {
                v2 = "1.5岁";
            } else {
                v2 = Integer.valueOf(ageEnd) / 12 + "岁";
            }

            ageSpan = v1 + "~" + v2;
        } else {
            ageSpan = ageStart + "~" + ageEnd + "月";
        }

        return ageSpan;
    }

    public Toy() {
        super();
    }

    public Toy(String id) {
        super(id);
    }

    public Brand getBrand() {
        return brand;
    }

    public void setBrand(Brand brand) {
        this.brand = brand;
    }

    public String getToyModel() {
        return toyModel;
    }

    public void setToyModel(String toyModel) {
        this.toyModel = toyModel;
    }

    @Length(min = 1, max = 64, message = "产品编号长度必须介于 1 和 64 之间")
    public String getToyNumber() {
        return toyNumber;
    }

    public void setToyNumber(String toyNumber) {
        this.toyNumber = toyNumber;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getIsBig() {
        return isBig;
    }

    public void setIsBig(String isBig) {
        this.isBig = isBig;
    }

    public String getParams() {
        return params;
    }

    public void setParams(String params) {
        this.params = params;
    }

    public int getMarketPrice() {
        return marketPrice;
    }

    public void setMarketPrice(int marketPrice) {
        this.marketPrice = marketPrice;
    }

    public int getSort() {
        return sort;
    }

    public void setSort(int sort) {
        this.sort = sort;
    }

    public int getPopularity() {
        return popularity;
    }

    public void setPopularity(int popularity) {
        this.popularity = popularity;
    }

    public String getAgeEnd() {
        return ageEnd;
    }

    public void setAgeEnd(String ageEnd) {
        this.ageEnd = ageEnd;
    }

    public String getAgeStart() {
        return ageStart;
    }

    public void setAgeStart(String ageStart) {
        this.ageStart = ageStart;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }


    public String getOnShelf() {
        return onShelf;
    }

    public void setOnShelf(String onShelf) {
        this.onShelf = onShelf;
    }

    public String getDetails() {
        return details;
    }

    public void setDetails(String details) {
        this.details = details;
    }

    public Stock getStock() {
        return stock;
    }

    public void setStock(Stock stock) {
        this.stock = stock;
    }

    public List<Image> getImages() {
        return images;
    }

    public void setImages(List<Image> images) {
        this.images = images;
    }

    public List<SubCategory> getSubCategories() {
        return subCategories;
    }

    public void setSubCategories(List<SubCategory> subCategories) {
        this.subCategories = subCategories;
    }

    public String getInstructionName() {
        return instructionName;
    }

    public void setInstructionName(String instructionName) {
        this.instructionName = instructionName;
    }

    public String getInstructionPath() {
        return instructionPath;
    }

    public void setInstructionPath(String instructionPath) {
        this.instructionPath = instructionPath;
    }

    public String getAges() {
        return ages;
    }

    public void setAges(String ages) {
        this.ages = ages;
    }

    public String getBrands() {
        return brands;
    }

    public void setBrands(String brands) {
        this.brands = brands;
    }

    public String getSorts() {
        return sorts;
    }

    public void setSorts(String sorts) {
        this.sorts = sorts;
    }

    public String getProductCategorys() {
        return productCategorys;
    }

    public void setProductCategorys(String productCategorys) {
        this.productCategorys = productCategorys;
    }

    public List<String> getSubCategoryIdList() {
        return subCategoryIdList;
    }

    public void setSubCategoryIdList(List<String> subCategoryIdList) {
        this.subCategoryIdList = subCategoryIdList;
    }

    public List<String> getParamList() {
        return paramList;
    }

    public void setParamList(List<String> paramList) {
        this.paramList = paramList;
    }

    public AppointmentCollection getAppointmentCollection() {
        return appointmentCollection;
    }

    public void setAppointmentCollection(AppointmentCollection appointmentCollection) {
        this.appointmentCollection = appointmentCollection;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Integer getToyCount() {
        return toyCount;
    }

    public void setToyCount(Integer toyCount) {
        this.toyCount = toyCount;
    }

    public Integer getToyStatus() {
        return toyStatus;
    }

    public void setToyStatus(Integer toyStatus) {
        this.toyStatus = toyStatus;
    }

    public Integer getToyStatusLast() {
        return toyStatusLast;
    }

    public void setToyStatusLast(Integer toyStatusLast) {
        this.toyStatusLast = toyStatusLast;
    }

    public Integer getRetailPrice() {
        return retailPrice;
    }

    public void setRetailPrice(Integer retailPrice) {
        this.retailPrice = retailPrice;
    }

    public Integer getStar() {
        return star;
    }

    public void setStar(Integer star) {
        this.star = star;
    }

    public String getExistStock() {
        return existStock;
    }

    public void setExistStock(String existStock) {
        this.existStock = existStock;
    }
}
